package formula.web.twork;

import javax.faces.context.ExceptionHandler;

public class ExceptionHandlerFactory extends javax.faces.context.ExceptionHandlerFactory {

	private javax.faces.context.ExceptionHandlerFactory mParent;
	/**
	 * the exceptionHandler needs to be cached, other many instances are created !
	 */
	private CustomExceptionHandler cachedHandler;

	public ExceptionHandlerFactory(javax.faces.context.ExceptionHandlerFactory parent) {
		mParent = parent;
	}

	@Override
	public ExceptionHandler getExceptionHandler() {
		if (cachedHandler == null) {
			ExceptionHandler parentHandler = mParent.getExceptionHandler();
			cachedHandler = new CustomExceptionHandler(parentHandler);
		}
		return cachedHandler;
	}
}
